import axios from 'axios';
const baseURL = import.meta.env.APP_APIHOST;

const instance = axios.create({ baseURL });

instance.interceptors.request.use(function (config) {
  const token = getToken();
  if (token) {
    config.headers['Authorization'] = `Bearer ${token}`;
  }
  return config;
});

const tokenKey = 'token';

const userNameKey = 'userName';

function getToken() {
  const token = localStorage.getItem(tokenKey);
  return token;
}

// 列表
export const getWorkList = (data: any) => instance.post('/api/work/list',data);

// 删除
export const getDelete = (data: any) => instance.post('/api/work/delete',data);

// 新建
export const getAddProject = (data: any) => instance.post('/api/work/create',data);

// 编辑
export const getEditProject = (data: any) => instance.post('/api/work/edit',data);

//
export const getProjectInfo = (data: any) => instance.post('/api/work/get',data);
